import request from "@/utils/request";

const BASE_URL = "/business/taskGyDispatch";

const TaskGyDispatchAPI = {
  /**
   * 根据合同id查询
   */
  loadByContractId(contractId: string, normId?: string) {
    if (!normId) {
      normId = '';
    }
    return request<any, TaskGyDispatchItem[]>({
      url: `${BASE_URL}/loadByContractId?contractId=${contractId}&normId=${normId}`,
      method: "get",
    });
  },

    /**
   * 根据合同id查询
   */
  loadByTaskId(taskId: string) {
      return request<any, TaskGyDispatchItem[]>({
        url: `${BASE_URL}/taskId?taskId=${taskId}`,
        method: "get",
      });
    },
  /**
   * 人员派单
   * @param data 表单数据
   */
  dispatch(data: TaskGyDispatchForm) {
    return request<any, TaskGyDispatchItem[]>({
      url: `${BASE_URL}/dispatch`,
      method: "post",
      data,
    });
  },
};

export default TaskGyDispatchAPI;


/** 工艺人员分配 */
export interface TaskGyDispatchForm {
  contractId: string;
  taskId: string;
  taskName: string;
  taskGyDispatches: TaskGyDispatchItem[];
}

export interface TaskGyDispatchItem {
  /** ID */
  id?: string;
  userId?: string;
  username?: string;
  /** 工艺名称 */
  name?: string;
  contractId?: string;
  taskId?: string;
  taskName?: string;
  normId?: string;
  normName?: string;
  dispatchTime?: string;
}

